package datatypes.kdTree;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class ArrayIterator<T> implements Iterator<T> {
	private T[] array;
	private int currentIndex = 0;
	
	public ArrayIterator(T[] array) {
		this.array = array;
	}

	@Override
	public boolean hasNext() {
		return currentIndex < array.length;
	}

	@Override
	public T next() throws NoSuchElementException {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		return array[currentIndex++];
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}

}
